﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

/// <summary>
/// Summary description for Focus
/// </summary>
public class Focus
{
    public void SetFocus(Control controlToFocus, Page webPageInstance)
	{
		//
		// TODO: Add constructor logic here
		//
       
        StringBuilder scriptFunction = new StringBuilder();
         string scriptClientId;
           scriptClientId = controlToFocus.ClientID;
         scriptFunction.Append("&lt;script language='javascript'>");
         scriptFunction.Append("document.getElementById('");
         scriptFunction.Append(scriptClientId);
        scriptFunction.Append( "').focus();");
          scriptFunction.Append("&lt;/script>");
        webPageInstance.ClientScript.RegisterStartupScript(GetType(),"SetFocusScript",scriptFunction.ToString());

	}
}
